import { IsContinueRender } from "@/core/renderer";
import type { CanvasContextType, LayerType, SerializableObject } from "@/core/public";

export type SerializableLayerObject = SerializableObject & {
  id: number
}

let autoIndex = 1;

export const getLayerId = () => {
  return autoIndex++
}

export default abstract class LayerBase {
  [key: string]: any
  abstract id: number
  abstract name: string
  abstract ctxType: CanvasContextType
  abstract readonly layerType: LayerType
  abstract render(ctx: CanvasRenderingContext2D): IsContinueRender
  abstract serialize(): SerializableLayerObject
  offscreenCanvasCtx = document.createElement('canvas').getContext('2d')
  rendered = false
  opacity = 1
  visible = true
}